Working with Client Data
This example shows how to store client data in an object on the terrain. This example uses the ICreator80 (CreateHoleOnTerrain), IGeometryCreator (CreateGeometryFromWKT), ITerrainHole80 (Position), INavigate80 (FlyTo) property and methods.
private void ClientData()
{
try
{
var SGWorld = new SGWorld80();
// create hole on terrain
var hole = SGWorld.Creator.CreateHoleOnTerrain(SGWorld.Creator.GeometryCreator.CreateGeometryFromWKT("POLYGON((6 6,11 6,11 11,6 11,6 6))"), string.Empty, "Hole on terrain");
hole.Position.Distance = 8000000;
// store client data with key "My Data" in the hole
hole.SetClientData("MyData", "Big hole");
// fly to the hole
SGWorld.Navigate.FlyTo(hole, ActionCode.AC_FLYTO);
MessageBox.Show("Created hole on terrain and saved client data(Big Hole) in it. Click ok to read client data from it");
// read client data with key "My Data" from the hole
var data = hole.GetClientData("MyData");
MessageBox.Show("Client data in the hole is:" + data);
}
catch (Exception ex)
{
MessageBox.Show("Unexpected error: " + ex.Message);
}
}
}
}